home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / Patient.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  2KB  |  100 lines

  1. // Patient.c  -- Simple patient record class
  2.  
  3. #include "Patient.h"
  4. #include "nihclIO.h"
  5.  
  6. #define THIS    Patient
  7. #define BASE    Object
  8. #define BASE_CLASSES BASE::desc()
  9. #define MEMBER_CLASSES String::desc()
  10. #define VIRTUAL_BASE_CLASSES
  11.  
  12. DEFINE_CLASS(Patient,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/Patient.c,v 3.0 90/05/15 22:43:56 kgorlen Rel $",NULL,NULL);
  13.  
  14. Patient::Patient(const String& nam, const String& num, int zip)
  15.     : _name(nam), _ssn(num), _zip(zip)
  16. {
  17. }
  18.  
  19. bool Patient::operator==(const Patient& p) const
  20. // Patient records will be considered equal when
  21. // all members are equal
  22. {
  23.     return _name == p._name
  24.         && _ssn == p._ssn
  25.         && _zip == p._zip;
  26. }
  27.  
  28. void Patient::operator=(const Patient& p)
  29. {
  30.     _name = p._name;
  31.     _ssn = p._ssn;
  32.     _zip = p._zip;
  33. }
  34.  
  35. int Patient::compare(const Object& p) const
  36. {
  37. // verify that p has species Patient
  38.     assertArgSpecies(p,classDesc,"compare");
  39. // compare Patient names
  40.     return _name.compare(((const Patient&)p)._name);   
  41. }
  42.  
  43. void Patient::deepenShallowCopy()
  44. {
  45.     _name.deepenShallowCopy();
  46.     _ssn.deepenShallowCopy();
  47. }
  48.  
  49. unsigned Patient::hash() const
  50. {
  51.     return _name.hash() ^ _ssn.hash() ^ _zip;
  52. }
  53.  
  54. bool Patient::isEqual(const Object& p) const
  55. {
  56.     return p.isSpecies(classDesc) && *this==(const Patient&)p;
  57. }
  58.  
  59. void Patient::printOn(ostream& strm) const
  60. {
  61.     strm << _name << ' ' << _ssn << ' ' << _zip;
  62. }
  63.  
  64. void Patient::dumpOn(ostream& strm) const
  65. {
  66.     strm << className() << '[' << endl;
  67.     strm << "name:\t" << _name << endl;
  68.     strm << "ssn:\t" << _ssn << endl;
  69.     strm << "zip:\t" << _zip << endl;
  70.     strm << ']' << endl;
  71. }
  72.  
  73. Patient::Patient(OIOin& strm)
  74.     : Object(strm), _name(strm), _ssn(strm)
  75. {
  76.     strm >> _zip;
  77. }
  78.  
  79. void Patient::storer(OIOout& strm) const
  80. {
  81.     Object::storer(strm);
  82.     _name.storeMemberOn(strm);
  83.     _ssn.storeMemberOn(strm);
  84.     strm << _zip;
  85. }
  86.  
  87. Patient::Patient(OIOifd& fd)
  88.     : Object(fd), _name(fd), _ssn(fd)
  89. {
  90.     fd >> _zip;
  91. }
  92.  
  93. void Patient::storer(OIOofd& fd) const
  94. {
  95.     Object::storer(fd);
  96.     _name.storeMemberOn(fd);
  97.     _ssn.storeMemberOn(fd);
  98.     fd << _zip;
  99. }
  100.